let user = document.querySelector(".user");
let tel = document.querySelector(".tel");
let yzm = document.querySelector(".yzm");
let pass = document.querySelector(".pass");

let userp = document.querySelector(".userp");
let telp = document.querySelector(".telp");
let yzmp = document.querySelector(".yzmp");
let passp = document.querySelector(".passp");

let check=document.querySelector('.check');
let checkp=document.querySelector('.check-p');
let now=document.querySelector('.now');

user.addEventListener("blur", function () {
    if (user.value.length < 6 || user.value.length > 20) {
        userp.style.display = "block";
    } else {
        userp.style.display = "none";
    }
});

tel.addEventListener("blur", function () {
    if (tel.value.length !== 11) {
        telp.style.display = "block";
    } else {
        telp.style.display = "none";
    }
});

yzm.addEventListener("blur", function () {
    if (yzm.value.length !== 4) {
        yzmp.style.display = "block";
    } else {
        yzmp.style.display = "none";
    }
});

pass.addEventListener("blur", function () {
    if (pass.value.length < 6 || user.value.length > 12) {
        passp.style.display = "block";
    } else {
        passp.style.display = "none";
    }
});

let obtain = document.querySelector("#obtain");

obtain.addEventListener("click", function () {
    let time = 60;
    obtain.disabled = true;
    let timeid = setInterval(function () {
        time--;
        obtain.textContent = `${time}秒之后可以重新获取`;
        if (time < 0) {
            time = time;
            obtain.textContent = `重新获取`;
            clearInterval(timeid);
            obtain.disabled = !true;
        }
    }, 1000);
});
ch()
check=true
function ch(){
    checkp.addEventListener('change',function(){
   
        if(check){
            now.disabled=false
            now.style.backgroundColor='#15bded'
            now.style.color = "#fff";
            check=false
            check.checked=true
            
        }else{
            now.disabled=true
            now.style.backgroundColor="#e0e0e0";
            now.style.color =  "#5f5f5f";
            check=true
            check.checked=false
        } 
    
    })
}

now.addEventListener('click',function(){
    
    if(user.value&&tel.value&&yzm.value&pass.value){
    alert(`注册成功点击确定进入首页`)   
    location.href='../home/home.html'
    now.disabled=true
    now.style.backgroundColor="#e0e0e0";
    now.style.color =  "#5f5f5f";
    
    user.value=''
    tel.value=''
    yzm.value=''
    pass.value=''
    }    
})